﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Web.Framework.Svc;
using AuthApi.Contracts.Search;

namespace AuthApi.Contracts
{
    [ServiceContract]
    public interface IAuthApiManagement
    {
        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        bool ChangePassword(AdUser user, string oldPassword, string newPassword);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        void ResetPassword(AdUser user);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        List<WebApplicationInfo> GetApplications(string nameLike);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        WebApplicationInfo GetApplicationById(int applicationId);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        WebApplicationInfo SaveApplication(WebApplicationInfo applicationInfo);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        void DeleteApplication(int applicationId);

        //[OperationContract]
        //List<RoleIncluded> GetRolesIncludedForApplication(int applicationId);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        void DeleteRoleForApplication(int applicationId, int roleId);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        RoleIncluded SaveRole(RoleIncluded role);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        List<RoleIncluded> GetRolesForApplication(int applicationId);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        UserWithApplication GetUserWithApplications(int companyId, string userName);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        List<AdUser> GetUsers(SearchUser search);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        AdUser GetUser(int applicationId, int companyId, string userName);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        AdUser SaveUser(AdUser adUser);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        AdUser SaveAppUser(AdUser adUser);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        UserWithApplication CreateUser(UserWithApplication user);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        List<Company> GetCompanies(string nameLike);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        Company SaveCompany(Company company);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        void DeleteCompany(int companyId);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        Company GetCompanyWithApplicationsById(int companyId);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        void DeleteOperation(int operationId);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        RoleIncluded GetRoleForApplicationById(int applicationId, int roleId);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        List<OperationIncluded> GetOperationsForApplication(int applicationId);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        OperationIncluded SaveOperation(OperationIncluded operation);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        OperationIncluded GetOperationById(int operationId);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        OperationIncluded GetOperation(SearchOperation search);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        void IncluirUsuarioEnAplicacion(int companyId, int applicationId, string userName);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        void BloquearUsuario(int companyId, int applicationId, string userName, bool bloquear);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        void DeleteUser(string userName);

        [OperationContract]
        [FaultContract(typeof(WebFrameworkFaultException))]
        bool ExistCompanyApplication(int companyId, int applicationId);
    }
}
